package com.geng.filter;

import com.geng.dto.MyRequest;
import com.geng.dto.MyResponse;
import com.geng.invoker.SendRequst;


import java.util.List;

public class FilterChain {
    private  int currentSize = 0;
    private  List<Filter> filterList;


    public FilterChain(List<Filter> filterList){
        this.filterList = filterList;
    }


    public void doFilter(MyRequest request, MyResponse response){
        if(currentSize == filterList.size()){
            SendRequst sendRequst = new SendRequst();
            sendRequst.deSendRequst(request);
            return;
        }
        filterList.get(currentSize++).doFilter(request,response,this);
    }
}
